package com.dxf.sysadmin.controller;

import com.dxf.common.utils.ResultJson;
import com.dxf.sysadmin.entity.Clazz;
import com.dxf.sysadmin.entity.Student;
import com.dxf.sysadmin.entity.qo.ClazzQo;
import com.dxf.sysadmin.entity.qo.MyPage;
import com.dxf.sysadmin.service.ClazzService;
import com.dxf.sysadmin.service.StudentService;
import com.dxf.sysadmin.utils.ExcelAnalysis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/student")
@Api(tags  = "StudentController|学生控制器")
public class StudentController {
    @Autowired
    private StudentService studentService;

    /**
     * @Description: 学生列表分页查询
     */
    @PostMapping("studentPage")
    @ApiOperation("学生列表分页查询")
    public ResultJson studentPage(@RequestBody MyPage qry){
        return studentService.studentPage(qry);
    }

    /**
     * @Description: 更具id列表删除学生
     */
    @PostMapping("delete")
    @ApiOperation(value = "更具id列表删除学生")
    public ResultJson deleteStudent(@RequestParam("list[]") List<Long> list){
        return studentService.deleteStudent(list);
    }

    /**
     * @Description: 新增或者更新学生
     */
    @PostMapping("saveOrUpdate")
    @ApiOperation(value="新增或者更新学生")
    public ResultJson saveOrUpdateStudent( @RequestBody Student obj){
        return studentService.saveOrUpdateStudent(obj);
    }

    /**
     * @Description: 下拉选项数据（班级，系统用户）
     */
    @GetMapping("selectData")
    @ApiOperation("下拉选项数据（班级，系统用户）")
    public ResultJson selectData(){
        return studentService.selectData();
    }

    /**
     *根据上传的excel插入学生
     */
    @PostMapping("upload")
    @ApiOperation("根据上传的excel插入学生")
    public ResultJson uploadFile(MultipartFile file) {
        return studentService.uploadFile(file);
    }
}
